package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteDictDataService;
import com.ruoyi.system.api.vo.SysDictDataVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 字典数据服务降级处理
 *
 * @author ZhangYu
 * @date 2024/5/28
 */
@Slf4j
@Component
public class RemoteDictDataFallbackFactory implements FallbackFactory<RemoteDictDataService> {

    @Override
    public RemoteDictDataService create(Throwable throwable) {
        return new RemoteDictDataService() {
            @Override
            public R<List<SysDictDataVO>> dictListByValue(List<String> dictValueList) {
                return R.fail("通过字典值列表查询数据字典列表失败:" + throwable.getMessage());
            }
        };
    }

}
